/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dp.vo;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.struts2.json.annotations.JSON;

/**
 *
 * @author db
 */
@Entity
@Table(name = "news_group")
//@NamedQueries({@NamedQuery(name = "NewsGroup.findAll", query = "SELECT n FROM NewsGroup n"), @NamedQuery(name = "NewsGroup.findByGroupid", query = "SELECT n FROM NewsGroup n WHERE n.groupruleid = :groupruleid")})
public class NewsGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "groupruleid")				
    private Integer groupruleid;				//用户组id	
    @Column(name = "grouprulename")
    private String grouprulename;				//组名称
    @Column(name = "mlocale")
    private String mlocale;						//客户端语言
    @JoinColumn(name = "marea", referencedColumnName = "areaid")   
	@ManyToOne
    private TAreainfo marea;
    @Column(name = "note")
    private String note;						//描述
    @Column(name = "grouptype")
    private Integer grouptype;					//用户组类型 1规则2自定义 default 1
    @Column(name = "userid")
    private String userid;						//创建人
    @Column(name = "createtime")          
	@Temporal(TemporalType.TIMESTAMP)
	private Date createtime;					//创建时间
    @JoinTable(name = "news_grouprule", joinColumns = {@JoinColumn(name = "groupruleid", referencedColumnName = "groupruleid")}, inverseJoinColumns = {@JoinColumn(name = "platformid", referencedColumnName = "platformid")})
    @ManyToMany
    private Set<NewsPlatforminfo> NewsPlatforminfoSet;

    public NewsGroup() {
    }

    public NewsGroup(Integer groupruleid) {
        this.groupruleid = groupruleid;
    }


    public Integer getGroupruleid() {
		return groupruleid;
	}

	public void setGroupruleid(Integer groupruleid) {
		this.groupruleid = groupruleid;
	}

	public String getGrouprulename() {
		return grouprulename;
	}

	public void setGrouprulename(String grouprulename) {
		this.grouprulename = grouprulename;
	}

	public String getMlocale() {
		return mlocale;
	}

	public void setMlocale(String mlocale) {
		this.mlocale = mlocale;
	}

	public TAreainfo getMarea() {
		return marea;
	}

	public void setMarea(TAreainfo marea) {
		this.marea = marea;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Integer getGrouptype() {
		return grouptype;
	}

	public void setGrouptype(Integer grouptype) {
		this.grouptype = grouptype;
	}
	
	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}
	
	@JSON(format="yyyy-MM-dd HH:mm:ss")
	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}

	@JSON(serialize=false)
    public Set<NewsPlatforminfo> getNewsPlatforminfoSet() {
		return NewsPlatforminfoSet;
	}

	public void setNewsPlatforminfoSet(Set<NewsPlatforminfo> newsPlatforminfoSet) {
		NewsPlatforminfoSet = newsPlatforminfoSet;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (groupruleid != null ? groupruleid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof NewsGroup)) {
            return false;
        }
        NewsGroup other = (NewsGroup) object;
        if ((this.groupruleid == null && other.groupruleid != null) || (this.groupruleid != null && !this.groupruleid.equals(other.groupruleid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.dp.vo.NewsGroup[groupruleid=" + groupruleid + "]";
    }

}
